package com.itcast.web.request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

@WebServlet("/requestDemo01")
public class RequestDemo01 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String method = request.getMethod();
        System.out.println(method);//GET
        String contextPath = request.getContextPath();
        System.out.println(contextPath);//
        String servletPath = request.getServletPath();
        System.out.println(servletPath);///ServletDemo03
        String queryString = request.getQueryString();
        System.out.println(queryString);//null
        String requestURI = request.getRequestURI();
        System.out.println(requestURI);//  /ServletDemo03
        StringBuffer requestURL = request.getRequestURL();
        System.out.println(requestURL);// http://localhost/ServletDemo03
        String protocol = request.getProtocol();
        System.out.println(protocol); //HTTP/1.1
        String remoteAddr = request.getRemoteAddr();
        System.out.println(remoteAddr);//0:0:0:0:0:0:0:1
    }
}
